<!--
 * @Description: 
 * @Author: xiongkuobiao
 * @Date: 2023-02-06 12:19:51
 * @LastEditors: xiongkuobiao
 * @LastEditTime: 2023-03-07 21:53:12
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // let obj = {};
    // console.log(JSON.stringify(obj) === "{}");

    // let arr1 = [1, 2];
    // let arr2 = arr1;

    // arr1.push(1111); // 浅拷贝成功
    // console.log(arr1, arr2);

    let obj = [
      {
        name: "111",
        children: [{ name: "222", children: [{ name: "333" }] }],
      },
      {
        name: "a111",
        children: [{ name: "222" }],
      },
      {
        name: "b111",
        children: [{ name: "b222", children: [{ name: "b333" }] }],
      },
    ];

    function deep(obj, add = "") {
      for (let key in obj) {
        if (obj[key].children && obj[key].children.length > 0) {
          add = add + "" + obj[key]["name"];
          obj[key]["explereeee"] = add;
          deep(obj[key].children, add);
        } else {
          obj[key]["explereeee"] = obj[key]["name"] + "" + add;
          add = "";
        }
        add = "";
      }
    }
    deep(obj);
    console.log(obj);
  </script>
</html>
